home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 223_01 / utoi.c < prev    next >
Text File  |  1980-01-01  |  640b  |  18 lines

  1. #include stdio.h
  2. /*
  3. ** utoi -- convert unsigned decimal string to integer nbr
  4. **          returns field size, else ERR on error
  5. */
  6.   static int xd,t;
  7.  
  8. utoi(decstr, nbr)  char *decstr;  int *nbr;  {
  9.   xd=0;
  10.   *nbr=0;
  11.   while((*decstr>='0')&(*decstr<='9')) {
  12.     t=*nbr;t=(10*t) + (*decstr++ - '0');
  13.     if ((t>=0)&(*nbr<0)) return ERR;
  14.     xd++; *nbr=t;
  15.     }
  16.   return xd;
  17.   }
  18.